{% block component_product_badges %}
    <div class="product-badges">
        {% block component_product_badges_discount %}
            {% set price = product.calculatedPrice %}
            {% if product.calculatedPrices.count > 0 %}
                {% set price = product.calculatedPrices.last %}
            {% endif %}

            {% set listPrice = price.listPrice.percentage > 0 %}
            {% set hasRange = product.calculatedPrices.count > 1 %}

            {% set displayParent = product.variantListingConfig.displayParent and product.parentId === null %}
            {% if displayParent %}
                {% set displayFromVariants = displayParent and price.unitPrice !== product.calculatedCheapestPrice.unitPrice %}
            {% endif %}

            {% if listPrice and not hasRange and not displayFromVariants %}
                <span class="badge bg-danger badge-discount">
                    <span class="visually-hidden">{{ 'listing.boxLabelDiscount'|trans|sw_sanitize }}</span>
                    <span aria-hidden="true">&#37;</span>
                </span>
            {% endif %}
        {% endblock %}

        {% block component_product_badges_topseller %}
            {% if product.markAsTopseller %}
                <span class="badge bg-warning badge-topseller">{{ 'listing.boxLabelTopseller'|trans|sw_sanitize }}</span>
            {% endif %}
        {% endblock %}

        {% block component_product_badges_new %}
            {% if product.isNew %}
                <span class="badge bg-success badge-new">{{ 'listing.boxLabelNew'|trans|sw_sanitize }}</span>
            {% endif %}
        {% endblock %}
    </div>
{% endblock %}
